# class Animal:
#     def __init__(self, name):
#         self.name = name
#     def eat(self):
#
#         print(f"一只叫{self.name}的小狗在吃肉")
#
#     def drink(self):
#         print(f"一只叫{self.name}的小狗在吃喝")
#
#     def sleep(self):
#         print(f"一只叫{self.name}的小狗在睡觉")
# class Dog(Animal):
#     def bark(self):
#         print(f"一只叫{self.name}的小狗在汪汪叫")
# # 题目3
# class Person:
#     def __init__(self,name,age):
#         self.name=name
#         self.__age=age
#     def get_age(self,age):
#         self.age=age
#     def set_age(self,age):
#         if self.age >= 0 and self.age >= 120:
#             self.age= age
#         else:
#             print(f"输入不正确")
#     def __str__(self):
#         return f"姓名：{self.name}年龄:{self.age}"
#
# # 题目4
# # 1. 使用代码在test.txt文件中写入"wow,so beautiful!".
# # 2. 使用 代码读取 `test.txt` 文件中的内容 并打印
# with open('test.txt','w',encoding='utf-8') as f:
#     buf = f.write('wow,so beautiful!')
#     print(buf)
#     # 题目5
# with open('a.txt','w',encoding='utf-8') as a:
#     auf = a.write('张三,李四,王五,赵六')
# with open('a.txt','r',encoding='utf-8') as c:
#     cuf = c.read()
#     my_list=cuf.split(',')
#     print(my_list)
#     # 题目6
with open('a.txt','w',encoding='utf-8') as d:
    duf = d.write('1,2,3,4,5,6,7')
with open('a.txt','r',encoding='utf-8') as g:
    guf = g.read()
    print(guf)
    guf_list=guf.split(',')
    print(guf_list)
num = 0
for i in guf_list:
    print(i)
    num += int(i)
print(num)

#
# if __name__ == '__main__':
#     info = Animal('哮天犬')
#     info.eat()
#     info.drink()
#     info.sleep()
#     info_1 = Dog('哮天犬')
#     info_1.bark()
#
#     p_1 =Person('小明',18)
#     p_1.set_age()
